import java.util.ArrayList;
import java.util.List;

/**
 * 分月饼
 *
 * 200分
 *
 * #回溯法 #动态规划
 */
public class Fenyueping {
    private static int res = 0;
    private static List<Integer> cakeMap;
    private static int base = 1;
    public static void main(String[] args) {
        Fenyueping demo = new Fenyueping();
        demo.xx(3, 12);
        demo.xx(3, 5);
        demo.xx(2, 4);
    }

    public void xx(int m, int n) {
        // 当只有一个人时， 那么就只有一种分法
        if (m == 1) {
            System.out.println(1);
            return;
        }
        // 总共有几种分法？
        res = 0;
        // 这里是基础， 最起码，一人一个
        base = 1;
        // 每人多少个？放到一个map中去
        cakeMap = new ArrayList<Integer>(m);
        // 这是什么意思？步间距
        // m = 1, space = 0;
        // m = 2, space = 3;
        // m = 3, space = 9;
        // m = 4, space = 18;
        int space = 3 * m * (m - 1) / 2;
        while (base * m + space < n) {
            base++;
        }
        for (int first = base; first <= n / m; first++) {
            cakeMap.add(first);
            moonCake(1, m, n - first);
            cakeMap.remove(0);
        }
        System.out.println(res);
    }

    private static void moonCake(int idx, int m, int n) {
        if (idx == m - 1) {
            if (n - cakeMap.get(idx - 1) >= 0 && n - cakeMap.get(idx - 1) <= 3) {
                res++;
            }
            return;
        }
        int lastCakes = cakeMap.get(idx - 1);
        int restM = m - idx;
        for (int i = lastCakes;i<=Math.min(lastCakes+3,n/restM);i++) {
            cakeMap.add(i);
            moonCake(idx+1,m,n-i);
            cakeMap.remove(cakeMap.size()-1);
        }
    }
}
